package com.suixinsanren.design.compound.demo02;

public class RubberDuck implements QuackAble {

    private final Observable observable;

    public RubberDuck() {
        this.observable = new Observable(this);
    }

    @Override
    public void quack() {
        System.out.println("吱吱吱");
        observable.notifyObserver();
    }

    @Override
    public void addObserver(Observer observer) {
        observable.addObserver(observer);
    }

    @Override
    public void notifyObserver() {
        observable.notifyObserver();
    }

    @Override
    public String toString() {
        return "橡皮鸭";
    }
}
